<template>
  <!-- 勘误查看页面 -->
  <view class="corrigendum_view">
    <view class="corrigendum_content">
      <view class="form-content" style="margin-top: 28rpx">
        <view class="form-item address">
          <view class="left"> 地址 </view>
          <view class="right">
            <view>{{ info.address }}</view>
          </view>
        </view>
        <view class="form-item">
          <view class="left"> 项目类型 </view>
          <view class="right">
            <view>{{ typeList[info.type] }}</view>
          </view>
        </view>
        <view class="form-item">
          <view class="left"> 项目联系人 </view>
          <view class="right">
            {{ info.contactsName }}
          </view>
        </view>
        <view class="form-item noBorder" @click="handleCall">
          <view class="left">项目联系电话 </view>
          <view class="right" style="color: #0091ff">
            <image class="phone" src="/static/images/call.png" mode="" />
            {{ info.phone }}
          </view>
        </view>
      </view>
      <view class="form-content">
        <view class="form-item" @click="toBuildingAdd">
          <view class="left">楼数</view>
          <view class="right"> <text style="margin-right: 10rpx;">{{ info.floorTotal }} </text> <uni-icons color="#ccc" size="18" :type="'arrowright'" ></uni-icons> </view>
        </view>
        <view class="form-item noBorder">
          <view class="left">梯数</view>
          <view class="right">{{ info.eleTotal }}</view>
        </view>
      </view>
      <!-- 项目图片 -->
      <view class="form-content">
        <view class="form-item">
          <view class="left">项目图片</view>
          <view class="imgBox" v-if="info.buildingImages && info.buildingImages.length">

            <imageDragSort :disabled="true" :list="info.buildingImages"></imageDragSort>
            <!-- <image
              @click="previewImg(index)"
              class="imgItem"
              v-for="(img, index) in info.buildingImages"
              :key="index"
              :src="img"
            >
            </image> -->
          </view>
          <view class="right" v-else>
            <text class="emptyImg">暂无图片 </text>
          </view>
        </view>
        <view class="form-item noBorder">
          <view class="left">项目备注</view>
          <view class="right">
            <view style="text-align: right;justify-content: flex-end;" v-if="info.buildingExt.buildingRemark && info.buildingExt.buildingRemark.length > 25">
              <view v-if="!showBuildingRemark" @click="showMmoreBuildingRemark" style="display: flex;">
                <view class="remark">
                  {{ info.buildingExt.buildingRemark || "-" }}
                </view>
              
                <uni-icons color="#ccc" size="18"
                :type="showBuildingRemark ? 'arrowup' : 'arrowdown'"></uni-icons>
              </view>
              <view v-if="showBuildingRemark" @click="showMlessBuildingRemark">{{ info.buildingExt.buildingRemark }}
                <uni-icons color="#ccc" size="18"
                :type="showBuildingRemark ? 'arrowup' : 'arrowdown'"></uni-icons>
              </view>
            
            </view>

            <view class="remakAll" v-else>
              {{ info.buildingExt.buildingRemark || '-' }}
            </view>
          </view>
        </view>
      </view>
      <!-- 停车信息 -->
      <view class="form-content">
        <view class="form-item">
          <view class="left">停车位信息</view>
          <view class="right">{{
            ["未知", "有停车位", "无停车位"][info.buildingExt.parkingSpot]
          }}</view>
        </view>
        <view class="form-item">
          <view class="left">保养人数要求</view>
          <view class="right">{{
            ["不限", "2人", "2人以上"][info.buildingExt.maintainPersonnel]
          }}</view>
        </view>
        <view class="form-item">
          <view class="left">驻点要求</view>
          <view class="right">{{
            ["", "不限", "需驻点"][info.buildingExt.stagnationPoint]
          }}</view>
        </view>
        <view class="form-item">
          <view class="left">预约要求</view>
          <view class="right">{{
            ["不限", "需要预约"][info.buildingExt.makeAppointment]
          }}</view>
        </view>
        <view class="form-item">
          <view class="left">救援抵达时间</view>
          <view class="right" v-if="info.buildingExt.rescueTime == 0">{{
            "30分钟以内"
          }}</view>
          <view class="right" v-else>{{
            `白天:${info.buildingExt.rescueDaytime}分钟内;
                      晚上:${info.buildingExt.rescueNight}分钟内`
          }}</view>
        </view>
        <view class="timeList noBorder">
          <view class="timeListLabel">
            <view class="left">保养作业时间</view>
            <view class="right" style="     text-align: right;" v-if="info.timeList && info.timeList.length"
              @click="showTimeList = !showTimeList">
              {{
                `星期${weekList[info.timeList[0].label]}:${info.timeList[0].timeStamp==null?'不限':info.timeList[0].timeStamp}`
              }}
              <uni-icons color="#ccc" size="18" :type="showTimeList ? 'arrowup' : 'arrowdown'" />
            </view>
            <view v-else class="right">不限</view>
          </view>
          <view class="byTimeBox" v-if="showTimeList">
            <view class="byTime" v-for="(item, index) in info.timeList" :key="index">
              <view class="byTime_left">{{
                "周" + weekList[item.label]
              }}</view>
              <view class="byTime_right" v-if="item.timeStamp!==null">
                <view v-for="(e,i) in item.timeStamp" :key="i" class="byTime_right_item">{{ e }}
                  <text v-if="i!=item.timeStamp">;</text>
                </view>
              </view>
              <view v-else>不限</view>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view class="save">
      <view v-if="status === 0">
        <view @click="handleCorrgendum">勘误</view>
      </view>
      <view v-else class="disable">{{
        ["", "已提交,待审批", "通过", "驳回"][status]
      }}</view>
    </view>
    <!-- 打电话对话框 -->
    <model width="508rpx" :visible="phoneVisible" :showTitle="false" :showCloseIcon="false" cancleTxt="取消" comfireTxt="确定"
      @cancle="phoneVisible = false" @comfire="comfireCall(info.phone)">
      <view class="conte">
        <view class="modelItem call">拨打电话 </view>
        <view class="modelItem"> {{ info.phone }} </view>
      </view>
    </model>
  </view>
</template>

<script>
import model from '@/components/model/index.vue';
import imageDragSort from '@/components/image-drag-sort/index.vue';
export default {
	components: {
		model,
		imageDragSort,
	},
	props: {
		typeList: {
			type: Array,
		},
		buildingId:{
			type:String,
			default:''
		}
	},
	data() {
		return {
			// inputDisable: false,
			info: { buildingExt: {}, buildingImages: [] },
			phoneVisible: false,
			status: 0,
			showTimeList: false, // 保养时间段的箭头
			showBuildingRemark: false,
			weekList: ['', '一', '二', '三', '四', '五', '六', '日'],
		};
	},
	methods: {
		showMmoreBuildingRemark() {
			this.showBuildingRemark = true;
		},
		showMlessBuildingRemark() {
			this.showBuildingRemark = false;
		},
		init(data) {
			console.log(data, 'data的值');
      
			this.info = data;
		},
		handleCall() {
			this.phoneVisible = true;
		},
		handleCorrgendum() {
			this.$emit('corrgendum');
		},
		// 拨打电话
		comfireCall(num) {
			this.phoneVisible = false;
			uni.makePhoneCall({
				phoneNumber: num,
				success: function () {
					// console.log("拨打电话成功");
				},
				fail() {
					// console.log('打电话失败了');
				},
			});
		},
		previewImg(i) {
			let sources = this.info.buildingImages.map((item) => {
				return {
					type: 'image',
					url: item,
				};
			});
			this.$previewMedia({
				sources,
				current: i,
			});
		},
		// 去楼栋添加页面
		toBuildingAdd() {
			uni.navigateTo({
				url: `/subpages/buildingInfos/index?buildingId=${this.buildingId}`,
			});
		},
	},
};
</script>

<style lang="scss" scoped>
.corrigendum_view {
  padding-bottom: 100rpx;

  .corrigendum_content {
    padding: 0 20rpx;
  }

  .header {
    display: flex;

    .header_left {
      width: 544rpx;
    }

    .header_right {
      display: flex;
    }
  }

  .conte {
    padding-bottom: 40rpx;
  }

  .modelItem {
    display: flex;
    justify-content: center;
    color: #999;
  }

  .call {
    font-size: 30rpx;
    color: #000;
    // opacity: 0.9;
    margin-bottom: 16rpx;
    font-weight: 600;
  }

  .form-content {
    width: 710rpx;
    box-sizing: border-box;
    background: #fff;
    margin: 0rpx 0 20rpx 0;
    padding: 0 20rpx;
    border-radius: 8rpx;
    margin-top: 16rpx;

    .address {
      textarea {
        min-height: 60rpx;
        width: 100%;
        height: 100rpx;
        align-items: center;
        display: flex;
        align-items: center;
        text-align: right;
      }
    }

    .form-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      // padding: 40rpx 0rpx;

      border-bottom: 2rpx solid #e9e9e9;
      font-size: 28rpx;
      padding: 28rpx 0;

      .unit {
        margin-left: 4rpx;
      }

      .left {
        // height: 78rpx;
        font-size: 28rpx;
        color: #333;
        width: 170rpx;
        display: flex;
        align-items: center;

        text {
          color: red;
          padding: 5rpx;
        }

        image {
          width: 28rpx;
          height: 28rpx;
          margin-left: 10rpx;
        }
      }

      .right {
        // height: 78rpx;
        display: flex;
        flex: 1;
        align-items: center;
        justify-content: flex-end;
        color: #666;
        text-align: right;

        view {
          // text-align: right;
          width: 100%;
          display: flex;
          justify-content: flex-end;
        }

        .remark {
          width: 300rpx;
          display: inline-block;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }

        .emptyImg {
          color: #ccc;
        }

        .phone {
          width: 32rpx;
          height: 32rpx;
        }
      }

      .imgBox {
        display: flex;

        image {
          width: 128rpx;
          height: 128rpx;
          // margin-right: 16rpx;
        }
      }

      .count {
        width: 218rpx !important;
        display: flex;
        height: 118rpx;
        align-items: center;
        justify-content: flex-end;

        input {
          display: flex;
          flex: 1;
          text-align: center;
          box-sizing: border-box;
          height: 60rpx;
          border-top: 2rpx solid #d3dbe1;
          border-bottom: 2rpx solid #d3dbe1;
        }

        view {
          display: flex;
          width: 60rpx;
          height: 60rpx;
          color: #828e96;
          align-items: center;
          box-sizing: border-box;
          justify-content: center;
          background: #f3f6f8;
          border: 2rpx solid #d3dbe1;
          // border-radius: 4rpx 0rpx 0rpx 4rpx;
        }
      }
    }

    .timeList {
      padding-bottom: 20rpx;

      .timeListLabel {
        display: flex;
        justify-content: space-between;
        font-size: 28rpx;
        // height: 78rpx;
        padding: 20rpx 0;
        align-items: center;

        .left {
          width: 200rpx;
        }

        .right {
          color: #666;
        }
      }

      .byTimeBox {
        background: #f6f6f6;

        .byTime {
          color: #666;
          display: flex;
          justify-content: space-between;
          padding: 16rpx 20rpx;
          border-bottom: 1rpx solid #e9e9e9;
          align-items: center;

          &_left {
            width: 160rpx;
          }

          &_right {
            // text-align: right;
            display: flex;
            justify-content: flex-end;
            flex-wrap: wrap;
            .byTime_right_item{
              margin-right: 10rpx;
            }
          }
        }
      }
    }

    .noBorder {
      border: none !important;
    }

    .addNotice {
      display: flex;
      flex-direction: column;

      .addNotice-title {
        width: 100%;
        align-items: flex-start;
        padding: 20rpx 0 28rpx 0;
        color: #999999;
      }

      .border {
        border: 2rpx solid #e9e9e9;
      }

      .imgBox {
        padding-bottom: 40rpx;
        margin: 0 20rpx;
        width: 100%;

        image {
          width: 112rpx;
          height: 112rpx;
          // border: 1rpx solid #ccc;
          margin-right: 18rpx;
        }

        textarea {
          width: 630rpx;
          margin: 20rpx;
        }

        .lenthTips {
          margin-right: 20rpx;
          color: #ccc;
          // width: 100%;
          display: flex;
          justify-content: flex-end;
        }
      }
    }
  }

  .save {
    display: flex;
    justify-content: center;
    padding: 14rpx 0;
    background: #fff;
    position: fixed;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 50;

    view {
      width: 710rpx;
      background: #0091ff;
      height: 70rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 8rpx;
      color: #fff;
    }

    .disable {
      background-color: #efefef;
      color: #cccccc;
    }
  }
}
</style>
